class Foo < ActiveRecord::Base
 validates_format_of :bar, :with=>%r{^\d{4}$}
end
